package com.rr.intTest;

/**
 * Java类型转换: int转double
 *
 * @author : RENBIAO
 * @createTime : 2021/6/17 16:04
 */
public class intToDouble {

    public static void main(String[] args) {

        int intNum1 = 0;
        int intNum2 = 6;
        int intNum3 = -865;

        //方法1：隐式转换
        double doubleNum1 = intNum1;
        double doubleNum2 = intNum2;
        double doubleNum3 = intNum3;
        System.out.println("intNum1转换后为【转换方法:】:" + doubleNum1);
        System.out.println("intNum2转换后为【转换方法:】:" + doubleNum2);
        System.out.println("intNum3转换后为【转换方法:】:" + doubleNum3);

        //方法2：Double.valueOf()
        double doubleNum4 = Double.valueOf(intNum1);
        double doubleNum5 = Double.valueOf(intNum2);
        double doubleNum6 = Double.valueOf(intNum3);
        System.out.println("intNum1转换后为【转换方法:Double.valueOf()】:" + doubleNum4);
        System.out.println("intNum2转换后为【转换方法:Double.valueOf()】:" + doubleNum5);
        System.out.println("intNum3转换后为【转换方法:Double.valueOf()】:" + doubleNum6);

    }
}
